/*
 * Course:    CS 590 Web Services
 * Semseter:  Spring 2009
 * Professor: Sedlemeyer
 * Project:   CHEAT (Code Help Educational Assignment Tool)
 * Due Date:  May 1, 2009
 * Team:      Sarcasm
 *            (Baker, Jason; Mitchell, Robin; Shie, Keith)
 */

package cheat.entities.keys;

import cheat.entities.AssignmentKeyword;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * Holds the composite primary key for the {@linkplain AssignmentKeyword} entity.
 *
 * @author Keith Shie
 */
@Embeddable
public class AssignmentKeywordPK implements Serializable {
  @Basic(optional = false)
  @Column(name = "uuid", nullable = false)
  private int uuid;
  @Basic(optional = false)
  @Column(name = "asgncntcd", nullable = false, length = 8)
  private String keywordCode;
  @Basic(optional = false)
  @Column(name = "value", nullable = false, length = 30)
  private String contentValue;

  public AssignmentKeywordPK() {
  }

  public AssignmentKeywordPK(int uuid, String keywordCode, String value) {
    this.uuid = uuid;
    this.keywordCode = keywordCode;
    this.contentValue = value;
  }

  public int getUuid() {
    return uuid;
  }

  public void setUuid(int uuid) {
    this.uuid = uuid;
  }

  public String getKeywordCode() {
    return keywordCode;
  }

  public void setKeywordCode(String keywordCode) {
    this.keywordCode = keywordCode;
  }

  public String getContentValue() {
    return contentValue;
  }

  public void setContentValue(String value) {
    this.contentValue = value;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (int) uuid;
    hash += (keywordCode != null ? keywordCode.hashCode() : 0);
    hash += (contentValue != null ? contentValue.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof AssignmentKeywordPK)) {
      return false;
    }
    AssignmentKeywordPK other = (AssignmentKeywordPK) object;
    if (this.uuid != other.uuid) {
      return false;
    }
    if ((this.keywordCode == null && other.keywordCode != null) || (this.keywordCode != null && !this.keywordCode.equals(other.keywordCode))) {
      return false;
    }
    if ((this.contentValue == null && other.contentValue != null) || (this.contentValue != null && !this.contentValue.equals(other.contentValue))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "cheat.entities.AssignmentKeywordPK[uuid=" + uuid + ", keywordCode=" + keywordCode + ", contentValue=" + contentValue + "]";
  }

}
